package com.drinks.yiniang.common.help;

import android.content.Context;
import android.content.Intent;

import com.drinks.yiniang.App;
import com.drinks.yiniang.ui.activity.MainActivity;
import com.drinks.yiniang.ui.activity.user.login.LoginActivity;
import com.drinks.yiniang.utils.SharedPreUtils;
import com.hansen.library.utils.StringUtils;

/**
 * Created by han on 2019/3/14 0014.
 */

public class LogoutHelp {

    public static void doLogout(boolean isToLogin) {
        if(App.getInstance() == null) {
            return;
        }

        Context mContext = App.getInstance().getApplicationContext();

        SharedPreUtils.getInstance().clearLoginSharedPreference();

        if(isToLogin && !LoginActivity.isActive) {
            Intent mIntent = new Intent(mContext, MainActivity.class);
            mIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivity(mIntent);
        }
    }
}
